
<?php 
phpinfo();
 ?>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>在线聊天</title>
	<script src="http://libs.baidu.com/jquery/2.1.1/jquery.min.js"></script>
	<style>
	.chat{border:2px solid gray;}
	</style>
	<script>
		$(function(){
			$('.submit').click(function(){
				var content = $('#talk').val();
				if($('.clear').attr('selected')){
					var clear = $('#clear').val();
				}else{
					var clear = 0;
				}
				$.ajax({
					url:'respond.php',
					type:'post',
					datatype:'json',
					data:{content:content,clear:clear},
					success:function(data){
						alert(data);
						$('.chat').html(data);
					}
				});
			});
		});
	</script>
</head>
<body>
	<div class="chat">
		<div class="orther">111</div>
		<div class="own">22</div>
	</div>
	<div class="">
		<textarea name="talk" id="talk" cols="30" rows="10"></textarea>
		<input type="button" class="submit" value="发表">
		<input type="radio" name="clear" id="clear" value="0">不清除
		<input type="radio" name="clear" id="clear" value="1">清除
	</div>
</body>
</html>